<?php
require('config.php');
$account = $_POST['account'];
$viIDs = $_POST['viids'];          //获得的是一个字符串
$viIDs_array = explode(",",$viIDs);//字符串转数组
$vsID = $_POST['vsid'];
$result_check_vote = mysql_query("select account from user_vs where vsID='$vsID'") or die(mysql_error());
$row_check_vote = mysql_fetch_array($result_check_vote);
if(!in_array($account,$row_check_vote)){
    $update_query = "update vote_item set vcount=vcount+1 where viID in ('$viIDs')";
    $update_query_p = "update users set points=points+10 where account='$account'";
    $result_update_p = mysql_query($update_query_p) or die(mysql_error());//更新积分
    $result_update = mysql_query($update_query) or die(mysql_error());    //更新票数

    $result_insert = mysql_query("insert into user_vs(account,vsID) values('$account','$vsID')") or die(mysql_error()); //插入user_vs表

    foreach($viIDs_array as $value){
     mysql_query("insert into user_vi(account,viID,vsID) values('$account','$value','$vsID')") or die(mysql_error());           //插入user_iv表
    }
    echo 1;
}else{
    echo 2;
    }

?>